package com.zzy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzy.system.domain.SaleOrderTraceSpus;
import com.zzy.system.domain.SaleOrderTraceSpusBatches;
import com.zzy.system.mapper.SaleOrderTraceSpusBatchesMapper;
import com.zzy.system.service.ISaleOrderTraceSpusBatchesService;
import com.zzy.system.service.ISaleOrderTraceSpusService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SaleOrderTraceSpusBatchesServiceImpl extends ServiceImpl<SaleOrderTraceSpusBatchesMapper, SaleOrderTraceSpusBatches> implements ISaleOrderTraceSpusBatchesService {
    private static final Logger log = LoggerFactory.getLogger(SaleOrderTraceSpusBatchesServiceImpl.class);

    @Override
    public void saveOrderTraceSpusBatches(List<SaleOrderTraceSpusBatches> saleOrderTraceSpusBatchesList) {
        if(!saleOrderTraceSpusBatchesList.isEmpty()){
            QueryWrapper<SaleOrderTraceSpusBatches> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("trace_spus_id", saleOrderTraceSpusBatchesList.get(0).getTraceSpusId());
            baseMapper.delete(queryWrapper);
            this.saveBatch(saleOrderTraceSpusBatchesList);
        }
    }
}